package backingbean;

import javax.faces.event.ActionEvent;

import oracle.adf.model.BindingContext;
import oracle.adf.model.binding.DCIteratorBinding;
import oracle.adf.view.rich.component.rich.input.RichInputText;

import oracle.binding.BindingContainer;

import oracle.binding.OperationBinding;

import oracle.jbo.Row;

public class EmployeeBean {
    private RichInputText firstName;
    private RichInputText lastName;
    private RichInputText mobileNumber;

    public EmployeeBean() {
    }

    public void setFirstName(RichInputText firstName) {
        this.firstName = firstName;
    }

    public RichInputText getFirstName() {
        return firstName;
    }

    public void setLastName(RichInputText lastName) {
        this.lastName = lastName;
    }

    public RichInputText getLastName() {
        return lastName;
    }

    public void setMobileNumber(RichInputText mobileNumber) {
        this.mobileNumber = mobileNumber;
    }

    public RichInputText getMobileNumber() {
        return mobileNumber;
    }

    public String callWebService() {

        
        
        return null;
    }

    public void callWebService(ActionEvent actionEvent) {
        
        String firstName = this.getFirstName().getValue().toString();
        String lastName = this.getLastName().getValue().toString();
        String mobileNumber = this.getMobileNumber().getValue().toString();
        BindingContainer dc = BindingContext.getCurrent().getCurrentBindingsEntry();       
        DCIteratorBinding inputItorBinding =(DCIteratorBinding) dc.get("arg0Iterator");
        OperationBinding opb = dc.getOperationBinding("getEmployeeDetails");
        
        Row row = inputItorBinding.getCurrentRow();
        row.setAttribute("firstName", firstName);
        row.setAttribute("lastName", lastName);
        row.setAttribute("mobileNumber", mobileNumber);
        
        Object returnVal = opb.execute();
        
        DCIteratorBinding returnItorBinding =(DCIteratorBinding) dc.get("ReturnIterator");
        Row responseRow = returnItorBinding.getCurrentRow();
        System.out.println(responseRow.getAttribute("firstName"));
        System.out.println(responseRow.getAttribute("lastName"));
        System.out.println(responseRow.getAttribute("mobileNumber"));
    }
}
